/**
 * 
 */
package edu.com.thao;

import java.util.Scanner;

/**
 * @author x401a
 * 
 */
public class SapXepMang {

	private static Scanner input;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		input = new Scanner(System.in);
		int[] a = new int[5];
		int i, j, tg;
		System.out.println("Nhap vao cac phan tu cua mang");
		for (i = 0; i < 5; i++) {
			System.out.print("a" + "[" + i + "]" + "=");
			a[i] = input.nextInt();
		}
		System.out.println("Dao nguoc cac phan tu cua mang:");
		for (i = 0; i < 5; i++) {
			for (j = i + 1; j < 5; j++) {
				tg = a[i];
				a[i] = a[j];
				a[j] = tg;
			}
			System.out.print("a" + "[" + i + "]" + "=");
			System.out.println(a[i]);
		}
		System.out.println("Sap xep cac phan tu cua mang theo chieu tang dan:");
		for (i = 0; i < 5; i++) {
			for (j = i + 1; j < 5; j++) {
				if (a[i] > a[j]) {
					tg = a[i];
					a[i] = a[j];
					a[j] = tg;
				}
			}
			System.out.print("a" + "[" + i + "]" + "=");
			System.out.println(a[i]);
		}
		System.out.println("Sap xep cac phan tu cua mang theo chieu giam dan:");
		for (i = 0; i < 5; i++) {
			for (j = i + 1; j < 5; j++) {
				if (a[i] < a[j]) {
					tg = a[i];
					a[i] = a[j];
					a[j] = tg;
				}
			}
			System.out.print("a" + "[" + i + "]" + "=");
			System.out.println(a[i]);
		}
	}

}
